<?php
////////////////////////////Common head
	$cache_time=10;
	$OJ_CACHE_SHARE=false;
	require_once("config/path_config.php");
	require_once('./include/cache_start.php');
    require_once('./include/db_info.inc.php');
	require_once('./include/setlang.php');
	$view_title= "Welcome To Online Judge";
 	$result=false;
///////////////////////////MAIN
	// 判断用户是否已登录
	if (!isset($_SESSION['user_id'])) {
        $error_url="loginpage.php";
        $error_desc=$MSG_Login;
        require("template/bs3/error.php");
    	exit(0);
	}
	
	$view_category="";
	$sql="select distinct source FROM `problem` order by source desc LIMIT 500";
	$result=pdo_query($sql);
	$category=array();
	foreach ($result as $row) {
		$cate=explode(" ",$row['source']);
		foreach($cate as $cat){
			array_push($category,trim($cat));	
		}
	}
	$category=array_unique($category);
	if (!$result){
		$view_category= "<h3>No Category Now!</h3>";
	}else{
		foreach ($category as $cat){
			if(trim($cat)=="") {
                continue;
			}
			$view_category.=
				"<div class='col-lg-3 col-xs-12'><a class='btn btn-primary' href='problemset.php?search=".htmlentities($cat,ENT_QUOTES,'UTF-8')."'>"
				.$cat
				."</a></div>";
		}
	}

/////////////////////////Template
require("template/".$OJ_TEMPLATE."/category.php");
/////////////////////////Common foot
if(file_exists('./include/cache_end.php'))
	require_once('./include/cache_end.php');

if ( file_exists("template/bs3/oj-footer.php") )
    require("template/bs3/oj-footer.php");
?>
